#ifndef MYENGINE_H
#define MYENGINE_H

#include "MyDefinitions.h"

class MyPlayer;
class MyMenu;
class MyGame;


 
/*! 
 *  \class MyEngine
 *  \brief Main class of the program, responsible for timing, trapping events and forwarding them to suitable classes (MyGame, MyMenu..) for further processing, SDL initializations and screen drawing. It also holds some key objects such as screen for all the drawing and acts as a parent object to other classes
 *  \author Peter Kosa
 *  \version 1.52
 *  \date    2006-2008
 */
class MyEngine{
	public:
     	MyEngine();			
		~MyEngine();		
		/*! init SDL, SDL_ttf, window icons */
		void init();			
		/*! recursively clears all resources being used, deinit SDL, TTF */
		void deinit();			
		/*! call deinit of actGame */
		void kill_game();
		/*! call deinit of actMenu */
		void kill_menu();		
		/*! call init of actGame */ 
		void init_game();		
		/*! call init of actMenu */
		void init_menu();		
    /*! method gets time intervals and recursively update everything moving in the game - passes the time to other game classes */
		void update(Uint32 _t);	
		/*! redraws screen by flipping buffers */		
		void redraw();
		/*! change engine state - essencial for switching between init phase, menu phase, game phase...  */			
		void goto_gs(engineState);
		/*! true if the engine should run, false means quit */
		bool is_running();		
		/*! flag for engine switching */
		bool switchEngineState;
		/*! base surface, all other surfaces are applied to this one */
		SDL_Surface* screen;
		/*! font used in the game	*/
		TTF_Font *font;
		/*! time from last update (in ms) */ 
		Uint32 _t;
	private:
		bool run;		
		/*! number of updates per second */		
		int updateCount;
		/*! fps calculations */		
		int fpsElapsedTime;
    /* state in which the engine is right now */
		engineState actEngineState;			
		/* state  to which the engine is switching */
    engineState switchingToEngineState; 
		/* MyMenu object for menu logic */
		MyMenu* actMenu;
		/* MyGame object for game logic */
		MyGame* actGame;
};
#endif
